using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ItemdetMap : EntityTypeConfiguration<Itemdet>
    {
        public ItemdetMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ITEM, t.LOCATION, t.EXPIRYDATE });

            // Properties
            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.LOCATION)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.BINLOCATION)
                .HasMaxLength(10);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Itemdet");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.LOCATION).HasColumnName("LOCATION");
            this.Property(t => t.BINLOCATION).HasColumnName("BINLOCATION");
            this.Property(t => t.ONHAND).HasColumnName("ONHAND");
            this.Property(t => t.ONHANDPW).HasColumnName("ONHANDPW");
            this.Property(t => t.ONORDER).HasColumnName("ONORDER");
            this.Property(t => t.PHYSICAL).HasColumnName("PHYSICAL");
            this.Property(t => t.INQTY).HasColumnName("INQTY");
            this.Property(t => t.INDATE).HasColumnName("INDATE");
            this.Property(t => t.OUTQTY).HasColumnName("OUTQTY");
            this.Property(t => t.OUTDATE).HasColumnName("OUTDATE");
            this.Property(t => t.ADJQTY).HasColumnName("ADJQTY");
            this.Property(t => t.ADJDATE).HasColumnName("ADJDATE");
            this.Property(t => t.MTD_ISSUE).HasColumnName("MTD_ISSUE");
            this.Property(t => t.MTD_RCPTS).HasColumnName("MTD_RCPTS");
            this.Property(t => t.MTD_ADJ).HasColumnName("MTD_ADJ");
            this.Property(t => t.YTD_ISSUE).HasColumnName("YTD_ISSUE");
            this.Property(t => t.YTD_RCPTS).HasColumnName("YTD_RCPTS");
            this.Property(t => t.YTD_ADJ).HasColumnName("YTD_ADJ");
            this.Property(t => t.IN_PW).HasColumnName("IN_PW");
            this.Property(t => t.OUT_PW).HasColumnName("OUT_PW");
            this.Property(t => t.ADJ_PW).HasColumnName("ADJ_PW");
            this.Property(t => t.MTDISSUEPW).HasColumnName("MTDISSUEPW");
            this.Property(t => t.MTDRCPTSPW).HasColumnName("MTDRCPTSPW");
            this.Property(t => t.MTD_ADJ_PW).HasColumnName("MTD_ADJ_PW");
            this.Property(t => t.YTDISSUEPW).HasColumnName("YTDISSUEPW");
            this.Property(t => t.YTDRCPTSPW).HasColumnName("YTDRCPTSPW");
            this.Property(t => t.YTD_ADJ_PW).HasColumnName("YTD_ADJ_PW");
            this.Property(t => t.PHYSICALPW).HasColumnName("PHYSICALPW");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.EXPIRYDATE).HasColumnName("EXPIRYDATE");
            this.Property(t => t.PHY_DATE).HasColumnName("PHY_DATE");
            this.Property(t => t.msrepl_tran_version).HasColumnName("msrepl_tran_version");

            // Relationships
            this.HasRequired(t => t.Item1)
                .WithMany(t => t.Itemdets)
                .HasForeignKey(d => d.ITEM);

        }
    }
}
